package org.example.listener;

import lombok.extern.slf4j.Slf4j;
import org.example.skytool.commom.IpUtil;
import org.example.skytool.security.StopWatchUtil;
import org.springframework.stereotype.Component;
import org.springframework.util.StopWatch;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletRequestEvent;
import javax.servlet.ServletRequestListener;
import javax.servlet.http.HttpServletRequest;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Map;


/**
 * @author 22449
 */
@Slf4j
@Component
public class RequestListener implements ServletRequestListener {

    @Resource
    private StopWatchUtil stopWatchUtil;

    @Override
    public void requestInitialized(ServletRequestEvent sre) {
        stopWatchUtil.start();
    }

    @Override
    public void requestDestroyed(ServletRequestEvent sre) {
        stopWatchUtil.stop();
    }

}
